const express = require("express")
const jwt = require("jsonwebtoken")
const expressJwt = require("express-jwt")
const app = express()
const secretkey = "test"


app.use(expressJwt({ secret: "test", algorithms: ["HS256"] }).unless({ path: [/^\/api\//] }))


app.get("/api/login", function(req, res) {
    res.send(jwt.sign({ username: "admin" }, "test", { expiresIn: "120s" }))
})

app.get("/getuser", function(req, res) {
    res.send("哈哈")
})



app.listen(80, function() {
    console.log("启动");
})